package com.unism.common.schedulerTask;

import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SchedulerTaskFactory {
	
	private static Logger log = LoggerFactory.getLogger(SchedulerTaskFactory.class.getName()) ;
	
	private static Scheduler scheduler ;
	
	static{
		if(scheduler == null){
			try {
				scheduler = new StdSchedulerFactory().getScheduler();
			} catch (SchedulerException e) {
				log.error(""+e);
			}
		}
	}

	/**
	 * 得到调度器唯一实例
	 * @return
	 */
	public static Scheduler getSingleScheduler(){
	    return scheduler ;
	}
	/**
	 * 关闭调度器
	 * @throws SchedulerException 
	 */
	public static void shutdownScheduler() throws SchedulerException{
		scheduler.shutdown() ;
	}

}
